// pages/user/helpCenter/helpCenter.js
var app = getApp();
var time= '';  // 服务时间
Page({

  /**
   * 页面的初始数据
   */
  data: {
    cate_sn: 'ALMmI8Yi',  // 位码
    content: [], // 常见问题
    phone:'',//客服电话
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    that.getArticle();  // 获取常见问题
    that.getPhone();
  },

  // 获取常见问题列表
  getArticle: function () {
    var that = this;
    // Ajax请求
    app.ajax({
      url: 'Common/Article/getArticle',
      data: { cate_sn: that.data.cate_sn },
      success: function (res) {
        if (res.data.code == 1000) {
          var content = res.data.data;
          var time= res.data.data[0].time;
          that.setData({
            content: content,
          })
        }
        console.log('请求结果',res)
      }
    })
  },

  // 跳转问题详情
  helpDetail(e) {
    var that = this;
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../helpDetail/helpDetail?id=' + id,
    })
  },
  // 跳转智能客服页面
  goServer(){
    var that = this;
    wx.navigateTo({
      url: '../../customService/customService',
    })
  },
  // 拨打客服电话
  tellPhone(e){
    var that = this;
    var phone = e.currentTarget.dataset.phone;
    wx.makePhoneCall({
      phoneNumber: phone 
    })
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },
  getPhone: function () {
    var that = this;
    // Ajax请求
    app.ajax({
      url: 'Common/Common/getSystemConfig',
      data: { key: 'company_hotline' },
      success: function (res) {
        if (res.data.code == 1000) {
          var content = res.data.data;
          that.setData({
            phone: content,
          })
        }
       
      }
    })
  },

})